package com.fuxi.cloud.desreport.render.utils;


/**
 * RenderUtil
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import com.fuxi.cloud.common.constant.ExpConstant;
import com.fuxi.cloud.desreport.render.b.b;
import com.fuxi.cloud.desreport.render.handler.data.CellReplaceHandler;
import com.fuxi.cloud.desreport.render.handler.data.GroupHandler;
import com.fuxi.cloud.desreport.render.handler.data.RecursionHandler;

public class RenderUtil {
    public static void a(Map paramMap, String paramString) {
        a(paramMap, paramString, (GroupHandler)null, Boolean.valueOf(false));
    }

    public static void a(Map paramMap, String paramString, GroupHandler paramGroupHandler, Boolean paramBoolean) {
        paramMap.forEach((paramObject1, paramObject2) -> {
            if (paramObject2 instanceof ArrayList) {
                List<JSONObject> list = (List)paramObject2;
                try {
                    Map map = (Map)list.stream().filter(l -> {
                        return ObjectUtil.isNotEmpty(l.getString(paramString));
                    }).collect(Collectors.groupingBy((l) -> {
                        return l.get(paramString);
                    }));                    paramMap.put(paramObject1, map);
                } catch (Exception exception) {
                    exception.printStackTrace();
                }
            } else {
                a((Map)paramObject2, paramString, paramGroupHandler, Boolean.valueOf(false));
            }
        });
        if (ObjectUtil.isNotEmpty(paramGroupHandler) && paramBoolean.booleanValue())
            paramGroupHandler.handler(paramMap, paramString);
    }

    public static void a(List<JSONObject> paramList, Map paramMap, RecursionHandler paramRecursionHandler, JSONObject paramJSONObject, String paramString) {
        AtomicReference<JSONObject> paramAtomicReference = new AtomicReference<>(new JSONObject());
        paramMap.forEach((paramObject1, paramObject2) -> {
            String str = paramObject1.toString();
            if (paramObject2 instanceof ArrayList) {
                List<JSONObject> list = (List)paramObject2;
                String str1 = paramString;
                if (ObjectUtil.isNotEmpty(paramString))
                    str1 = paramString + "_";
                list = paramRecursionHandler.doList(str, list, paramJSONObject, str1 + str);
                for (JSONObject jSONObject1 : list) {
                    JSONObject jSONObject2 = paramRecursionHandler.doObj(str, jSONObject1, paramJSONObject);
                    if (ObjectUtil.isNotEmpty(paramJSONObject)) {
                        jSONObject2.putAll((Map)paramJSONObject);
                        paramList.add(jSONObject2);
                    }
                }
            } else {
                if (ObjectUtil.isNotEmpty(paramString))
                    str = paramString + "_" + paramObject1.toString();
                LinkedList<JSONObject> linkedList = new LinkedList();
                paramAtomicReference.set(paramRecursionHandler.doMap(str, (Map)paramObject2, paramAtomicReference.get()));
                a(linkedList, (Map)paramObject2, paramRecursionHandler, paramAtomicReference.get(), str);
            }
        });
    }

    public static List<Map<String, Object>> a(List<Map<String, Object>> paramList, String paramString) {
        return (List<Map<String, Object>>)paramList.stream().sorted(Comparator.comparing(paramMap -> paramMap.get(paramString).toString())).collect(Collectors.toList());
    }

    public static List<JSONObject> b(List<JSONObject> paramList, String paramString) {
        return (List<JSONObject>)paramList.stream().sorted(Comparator.comparing(paramJSONObject -> paramJSONObject.get(paramString).toString())).collect(Collectors.toList());
    }

    public static Map c(List<Map<String, Object>> paramList, String paramString) {
        return (Map)paramList.stream().filter(paramMap -> ObjectUtil.isNotEmpty(paramMap.get(paramString))).collect(Collectors.groupingBy(paramMap -> paramMap.get(paramString)));
    }
    /**
     * 根据map的key排序
     *
     * @param map 待排序的map
     * @param isDesc 是否降序，true：降序，false：升序
     * @return 排序好的map
     * @author zero 2019/04/08
     */
    public static <K extends Comparable<? super K>, V> Map<K, V> sortByKey(Map<K, V> map, boolean isDesc) {
        Map<K, V> result = Maps.newLinkedHashMap();
        if (isDesc) {
            map.entrySet().stream().sorted(Map.Entry.<K, V>comparingByKey().reversed())
                    .forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
        } else {
            map.entrySet().stream().sorted(Map.Entry.<K, V>comparingByKey())
                    .forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
        }
        return result;
    }

    /**
     * 根据map的value排序
     *
     * @param map 待排序的map
     * @param isDesc 是否降序，true：降序，false：升序
     * @return 排序好的map
     * @author zero 2019/04/08
     */
    public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map, boolean isDesc) {
        Map<K, V> result = Maps.newLinkedHashMap();
        if (isDesc) {
            map.entrySet().stream().sorted(Map.Entry.<K, V>comparingByValue().reversed())
                    .forEach(e -> result.put(e.getKey(), e.getValue()));
        } else {
            map.entrySet().stream().sorted(Map.Entry.<K, V>comparingByValue())
                    .forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
        }
        return result;
    }
//    public static <K extends Comparable<? super K>, V> Map<K, V> a(Map<K, V> var0, boolean var1) {
//        LinkedHashMap var2 = Maps.newLinkedHashMap();
//        if (var1) {
//            var0.entrySet().stream().sorted(Map.Entry.comparingByKey().reversed()).forEachOrdered((var1x) -> {
//                var2.put(var1x.getKey(), var1x.getValue());
//            });
//        } else {
//            var0.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered((var1x) -> {
//                var2.put(var1x.getKey(), var1x.getValue());
//            });
//        }
//
//        return var2;
//    }
//
//    public static <K, V extends Comparable<? super V>> Map<K, V> b(Map<K, V> var0, boolean var1) {
//        LinkedHashMap var2 = Maps.newLinkedHashMap();
//        if (var1) {
//            var0.entrySet().stream().sorted(Map.Entry.comparingByValue().reversed()).forEachOrdered((var1x) -> {
//                Comparable var10000 = (Comparable)var2.put(var1x.getKey(), var1x.getValue());
//            });
//        } else {
//            var0.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEachOrdered((var1x) -> {
//                Comparable var10000 = (Comparable)var2.put(var1x.getKey(), var1x.getValue());
//            });
//        }
//
//        return var2;
//    }

    public void a(List<Map> paramList, Map paramMap, String paramString) {
        paramMap.forEach((paramObject1, paramObject2) -> {
            if (paramObject2 instanceof ArrayList) {
                HashMap<Object, Object> hashMap = new HashMap<>();
                List list = (List)paramObject2;
                hashMap.put(paramObject1.toString(), Integer.valueOf(list.size()));
                paramList.add(hashMap);
            } else {
                a((List)paramList, (Map)paramObject2, paramString);
            }
        });
    }

    public static List<b> a(JSONObject paramJSONObject) {
        ArrayList<b> arrayList = new ArrayList();
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && str1.indexOf("group(") > -1) {
                        String str2 = RegexMatches.b(str1, 2).replace(")", "");
                        if (ObjectUtil.isNotEmpty(str2)) {
                            b b = new b();
                            b.setColumn(str2);
                            b.setDirection("up");
                            arrayList.add(b);
                        }
                    }
                }
            }
        Collections.reverse(arrayList);
        return arrayList;
    }

    public static List<String> b(JSONObject paramJSONObject) {
        ArrayList<String> arrayList = new ArrayList();
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && (str1.indexOf("group(") > -1 || str1.indexOf("groupRight(") > -1)) {
                        String str2 = RegexMatches.b(str1, 2).replace(")", "");
                        if (ObjectUtil.isNotEmpty(str2))
                            arrayList.add(str2);
                    }
                }
            }
        Collections.reverse(arrayList);
        return arrayList;
    }

    public static b c(JSONObject paramJSONObject) {
        b b = null;
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && str1.indexOf("groupRight(") > -1) {
                        String str2 = str.substring(str.lastIndexOf("}") + 1);
                        b = new b();
                        String str3 = RegexMatches.b(str1, 2).replace(")", "");
                        b.setColumn(str3);
                        b.setSuffixText(str2);
                        b.setDirection("right");
                    }
                }
            }
        return b;
    }

    public static List<b> d(JSONObject paramJSONObject) {
        ArrayList<b> arrayList = new ArrayList();
        for (Map.Entry entry : paramJSONObject.entrySet()) {
            Object object = entry.getValue();
            if (object instanceof JSONObject) {
                b b = c((JSONObject)object);
                if (ObjectUtil.isNotEmpty(b))
                    arrayList.add(b);
            }
        }
        return arrayList;
    }

    public static String e(JSONObject paramJSONObject) {
        String str = "";
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str1 = jSONObject1.getString("aggregate");
                if (ObjectUtil.isNotEmpty(str1)) {
                    String str2 = jSONObject1.getString("text");
                    if (ObjectUtil.isNotEmpty(str2))
                        str = str2;
                }
            }
        return str;
    }

    public static List<JSONObject> f(JSONObject paramJSONObject) {
        ArrayList<JSONObject> arrayList = new ArrayList();
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && (str1.indexOf("group(") > -1 || str1.indexOf("groupRight(") > -1)) {
                        String str2 = RegexMatches.b(str1, 2).replace(")", "");
                        if (ObjectUtil.isNotEmpty(str2))
                            arrayList.add(jSONObject1);
                    }
                }
            }
        return arrayList;
    }

    public static List<String> g(JSONObject paramJSONObject) {
        ArrayList<String> arrayList = new ArrayList();
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && str1.indexOf("dynamic(") > -1) {
                        String str2 = RegexMatches.b(str1, 2).replace(")", "");
                        if (ObjectUtil.isNotEmpty(str2))
                            arrayList.add(str2);
                    }
                    if (ObjectUtil.isNotEmpty(str1) && a(str1, ExpConstant.FREEMARKER_FUNCTION).booleanValue())
                        arrayList.add(str1);
                }
            }
        Collections.reverse(arrayList);
        return arrayList;
    }

    public static List<JSONObject> h(JSONObject paramJSONObject) {
        LinkedList<JSONObject> linkedList = new LinkedList();
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    String str1 = RegexMatches.a(str, 2);
                    if (ObjectUtil.isNotEmpty(str1) && (str1.indexOf("dynamic(") > -1 || a(str1, ExpConstant.FREEMARKER_FUNCTION).booleanValue())) {
                        String str2 = RegexMatches.b(str1, 2).replace(")", "");
                        if (ObjectUtil.isNotEmpty(str2))
                            linkedList.add(jSONObject1);
                    }
                }
            }
        return linkedList;
    }

    public static Map a(List<Map<String, Object>> paramList, List<b> paramList1) {
        if (ObjectUtil.isNotEmpty(paramList1)) {
            Map map = (Map)paramList.stream().collect(Collectors.groupingBy(paramMap -> paramMap.get(((b)paramList.get(0)).getColumn())));
            paramList1.remove(0);
            for (b b : paramList1)
                a(map, b.getColumn());
            return map;
        }
        return null;
    }

    public static JSONArray a(Map<String, JSONObject> paramMap) {
        JSONArray jSONArray = new JSONArray();
        if (ObjectUtil.isNotEmpty(paramMap))
            for (Map.Entry<String, JSONObject> entry : paramMap.entrySet()) {
                JSONObject jSONObject = (JSONObject)entry.getValue();
                Integer[] arrayOfInteger = (Integer[])jSONObject.get("merge");
                String str1 = jSONObject.getString("cellIndex");
                String str2 = jSONObject.getString("rowIndex");
                if (ObjectUtil.isNotEmpty(arrayOfInteger)) {
                    Integer integer1 = arrayOfInteger[0];
                    Integer integer2 = Integer.valueOf(Integer.parseInt(str2) + integer1.intValue());
                    Integer integer3 = Integer.valueOf(Integer.parseInt(arrayOfInteger[1].toString()) + 65 + Integer.parseInt(str1));
                    char c = (char)Integer.parseInt(integer3.toString());
                    jSONArray.add(String.valueOf(c) + str2 + ":" + String.valueOf(c) + integer2);
                }
                System.out.println("");
            }
        return jSONArray;
    }

    public static JSONArray b(Map<String, JSONObject> paramMap) {
        JSONArray jSONArray = new JSONArray();
        if (ObjectUtil.isNotEmpty(paramMap))
            for (Map.Entry<String, JSONObject> entry : paramMap.entrySet()) {
                Object object = entry.getKey();
                JSONObject jSONObject = (JSONObject)entry.getValue();
                JSONArray jSONArray1 = (JSONArray)jSONObject.get("merge");
                String str = jSONObject.getString("rowIndex");
                if (ObjectUtil.isNotEmpty(jSONArray1)) {
                    Integer integer1 = jSONArray1.getInteger(1);
                    Integer integer2 = Integer.valueOf(Integer.parseInt(object.toString()) + 1);
                    Integer integer3 = Integer.valueOf(integer2.intValue() + Integer.parseInt(integer1.toString()));
                    Integer integer4 = Integer.valueOf(Integer.parseInt(str) + 1);
                    jSONArray.add(ExcelColumn.a(integer2) + integer4 + ":" + ExcelColumn.a(integer3) + integer4);
                }
                System.out.println("");
            }
        return jSONArray;
    }

    public static void a(JSONObject paramJSONObject, Integer paramInteger) {
        String str = paramJSONObject.getString("text");
        Set<String> set = RegexMatches.c(str);
        if (ObjectUtil.isNotEmpty(set))
            for (String str1 : set) {
                Integer integer = Integer.valueOf(ExcelColumn.a(str1, str1.length()));
                integer = Integer.valueOf(integer.intValue() + paramInteger.intValue() - integer.intValue() + 1);
                String str2 = ExcelColumn.a(integer);
                str = str.replace(str1, str2);
            }
        paramJSONObject.put("text", str);
    }

    public static JSONObject a(JSONObject paramJSONObject, CellReplaceHandler paramCellReplaceHandler, String... paramVarArgs) {
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str))
                    for (String str1 : paramVarArgs) {
                        if (str.indexOf(str1) != -1) {
                            String str2 = paramCellReplaceHandler.handler(paramJSONObject, str);
                            jSONObject1.put("text", str2);
                        }
                    }
            }
        return paramJSONObject;
    }

    public static JSONObject b(JSONObject paramJSONObject, CellReplaceHandler paramCellReplaceHandler, String... paramVarArgs) {
        for (Map.Entry entry : paramJSONObject.entrySet()) {
            Object object = entry.getValue();
            if (object instanceof JSONObject)
                a((JSONObject)object, paramCellReplaceHandler, paramVarArgs);
        }
        return paramJSONObject;
    }

    public static Boolean a(JSONObject paramJSONObject, String... paramVarArgs) {
        Boolean bool = Boolean.valueOf(false);
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str))
                    for (String str1 : paramVarArgs) {
                        if (str.indexOf(str1) != -1)
                            bool = Boolean.valueOf(true);
                    }
            }
        return bool;
    }

    public static Boolean a(String paramString, String... paramVarArgs) {
        Boolean bool = Boolean.valueOf(false);
        if (ObjectUtil.isNotEmpty(paramString))
            for (String str : paramVarArgs) {
                if (paramString.indexOf(str) != -1)
                    bool = Boolean.valueOf(true);
            }
        return bool;
    }

    public static Boolean a(JSONObject paramJSONObject, String[] paramArrayOfString1, String[] paramArrayOfString2) {
        Boolean bool1 = Boolean.valueOf(false);
        Boolean bool2 = Boolean.valueOf(true);
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str)) {
                    for (String str1 : paramArrayOfString1) {
                        if (str.indexOf(str1) != -1)
                            bool1 = Boolean.valueOf(true);
                    }
                    for (String str1 : paramArrayOfString2) {
                        if (str.indexOf(str1) != -1)
                            bool2 = Boolean.valueOf(false);
                    }
                }
            }
        return Boolean.valueOf((bool1.booleanValue() && bool2.booleanValue()));
    }

    public static Boolean b(JSONObject paramJSONObject, String... paramVarArgs) {
        Boolean bool = Boolean.valueOf(true);
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        if (jSONObject instanceof JSONObject)
            for (Map.Entry entry : jSONObject.entrySet()) {
                JSONObject jSONObject1 = (JSONObject)entry.getValue();
                String str = jSONObject1.getString("text");
                if (ObjectUtil.isNotEmpty(str))
                    for (String str1 : paramVarArgs) {
                        if (str.indexOf(str1) != -1)
                            bool = Boolean.valueOf(false);
                    }
            }
        return bool;
    }

    public static Boolean b(String paramString, String... paramVarArgs) {
        Boolean bool = Boolean.valueOf(true);
        if (ObjectUtil.isNotEmpty(paramString))
            for (String str : paramVarArgs) {
                if (paramString.indexOf(str) != -1)
                    bool = Boolean.valueOf(false);
            }
        return bool;
    }

    public static String i(JSONObject paramJSONObject) {
        for (Map.Entry entry : paramJSONObject.entrySet()) {
            JSONObject jSONObject = (JSONObject)entry.getValue();
            String str1 = jSONObject.getString("aggregate");
            String str2 = jSONObject.getString("direction");
            String str3 = jSONObject.getString("text");
            if ((ObjectUtil.isNotEmpty(str1) && str1.equals("eachTitle")) || (ObjectUtil.isNotEmpty(str2) && str2.equals("right")))
                return str3;
        }
        return null;
    }

    public static JSONObject j(JSONObject paramJSONObject) {
        JSONObject jSONObject = paramJSONObject.getJSONObject("cells");
        for (Map.Entry entry : jSONObject.entrySet()) {
            JSONObject jSONObject1 = (JSONObject)entry.getValue();
            String str1 = jSONObject1.getString("direction");
            String str2 = jSONObject1.getString("text");
            if (ObjectUtil.isNotEmpty(str1) && str1.equals("right"))
                return null;
        }
        return jSONObject;
    }

//    public static void main(String[] args) {
//        String str = "[{\"region\":\"\",\"province\":\"\",\"sales\":\"1066789\",\"saleDate\":\"1\",\"gift\":\"15546\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"2084\",\"saleDate\":\"1\",\"gift\":\"20-0\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20000\",\"saleDate\":\"1\",\"gift\":\"2000\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"29885\",\"saleDate\":\"1\",\"gift\":\"2090\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"18327\",\"saleDate\":\"1\",\"gift\":\"10800\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"29000\",\"saleDate\":\"1\",\"gift\":\"109000\",\"proportion\":\"50%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"10800\",\"saleDate\":\"1\",\"gift\":\"1800\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"1762789\",\"saleDate\":\"2\",\"gift\":\"17346\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"60084\",\"saleDate\":\"2\",\"gift\":\"52000\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"50000\",\"saleDate\":\"2\",\"gift\":\"4000\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20485\",\"saleDate\":\"2\",\"gift\":\"2050\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"151327\",\"saleDate\":\"2\",\"gift\":\"10050\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"24000\",\"saleDate\":\"2\",\"gift\":\"1500\",\"proportion\":\"50%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"10000\",\"saleDate\":\"2\",\"gift\":\"1090\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"1062789\",\"saleDate\":\"3\",\"gift\":\"15946\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20084\",\"saleDate\":\"3\",\"gift\":\"2080\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20000\",\"saleDate\":\"3\",\"gift\":\"2700\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20885\",\"saleDate\":\"3\",\"gift\":\"3400\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"151327\",\"saleDate\":\"3\",\"gift\":\"35000\",\"proportion\":\"15%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"20000\",\"saleDate\":\"3\",\"gift\":\"30600\",\"proportion\":\"50%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"10000\",\"saleDate\":\"3\",\"gift\":\"3000\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"166549\",\"saleDate\":\"1\",\"gift\":\"16788\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"466549\",\"saleDate\":\"2\",\"gift\":\"56788\",\"proportion\":\"10%\"},{\"region\":\"\",\"province\":\"\",\"sales\":\"366549\",\"saleDate\":\"3\",\"gift\":\"66788\",\"proportion\":\"10%\"}]";
//        List<JSONObject> list = (List)JSONArray.parse(str);
//        Map<Comparable, ?> map = (Map)list.stream().collect(Collectors.groupingBy(paramMap -> paramMap.get("region")));
//        map = a(map, false);
//        a(map, "province");
//        map = a(map, false);
//        a(map, "saleDate");
//        map = a(map, false);
//        System.out.println("");
//    }
}
